#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
    int A, B;
    for (int Num = 10000; Num <= 99999; Num++)
    {
        int sum = 0;
        int first = 10000;
        while (first != 1)
        {
            A = Num / first;
            B = Num - A * first;
            sum += A * B;
            first /= 10;
        }
        if (sum == Num)
        {
            printf("%d ", Num);
        }
    }
    return 0;
}